package mapreduceFilterPath;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.mapreduce.lib.db.DBWritable;

public class WordRecoder implements Writable, DBWritable {
	public String word;
	public int count;

	@Override
	public void write(PreparedStatement ps) throws SQLException {
		ps.setString(1, this.word);
		ps.setInt(2, this.count);
	}

	@Override
	public void readFields(ResultSet rs) throws SQLException {
		this.word = rs.getString(1);
		this.count = rs.getInt(2);

	}

	@Override
	public void write(DataOutput out) throws IOException {
		Text.writeString(out, this.word);
		out.writeInt(count);

	}

	@Override
	public void readFields(DataInput in) throws IOException {
		this.word = Text.readString(in);
		this.count = in.readInt();

	}

}
